<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/fuman/js/oversea.js"></script>
<script language="javascript">
	function getcang()
	{
		var endhouse = $("#seawarehouse").val();
		var shopname = $("#shopname").val();
		if(endhouse.indexOf('Amazon') >=0)
		{
			if(shopname=="")
			{
				alert("目的地为Amazon时，必须选择店铺");
				return;
			}
	
		}	
	}
	$(document).ready(function(){
		$("#p_search").click(function(){
			var psearch_key = $("#psearch_key").val();
			if(psearch_key){
				//搜索该商品编号对应的价格信息
				$.post("/oversea/ajaxbutton?op=searchProductSku",{"psearch_key": psearch_key},function(data){
					if(data)
					{
						$("#search_content").html('');
						//alert(JSON.stringify(data));return false;
						//$("#hidden_data").val(JSON.stringify(data));	//json转字符串
						//datalist = eval(data.listsku);
						var rs_str = '<table border="0" id="search_rs" cellpadding="5px"><tr><td colspan="9"><a href="javascript:void(0);">[关闭-搜索结果]需要的打勾</a></td></tr><tr class="thead"><td>&nbsp;</td><td width=120>商品SKU</td><td >商品名称</td></tr>';
						for(var i=0;i<data.length;i++){
							rs_str += '<tr><td><input type="checkbox" value="'+i+'"></td><td>'+data[i].sku+'</td><td>'+data[i].name+'</td></td>';
						}
						rs_str += '<tr><td colspan="9"><a href="javascript:void(0);">[关闭-搜索结果]</a></td></tr></table>';
						$(document.body).append(rs_str);
						$("#search_rs").css("left","400px");
						$("#search_rs").css("top","270px");
						$("#search_rs a").click(function(){
							$("#search_rs").remove();
						});
						$("#search_rs input[type='checkbox']").click(function(){
							if(this.checked){
								//添加sku
								var content = $.trim($("#sku").val());
									var newContent = content+"\n"+data[this.value].sku;
									$("#sku").val(newContent);
							}else{
								//移除sku
								var content = $("#sku").val();
								var result = content.replace(data[this.value].sku,"");
								$("#sku").val(result);
							}

						});

					}else{
						//alert(data.code);return false;
						$("#skuerr").html(data.msg).css('color','red');
						$('#price').val('');
					}
				},"json");
			}else{
				$("#search_content").html('没有输入任何数据!').css('color','red');
			}


		});

	});
</script>
<title>申请库存</title>
<body class="withvernav">
<div class="bodywrapper">
 {{include file='/public/leftmenu.tpl'}}
    <div class="centercontent">
    
       <div class="pageheader notab">
            <h1 class="pagetitle">申请调拨</h1>
            <span class="pagedesc"></span>
            <div class="menulist">
        		<ul class="profile_summary">
                        <li class="current"><a href="/oversea/purchasinglist">调拨申请列表</a></li>
                        
                    </ul>
               </div>
        </div><!--pageheader-->
        	
        <div id="contentwrapper" class="contentwrapper">
        	
        	<div id="basicform" class="subcontent">
					<form class="stdform stdform2"  id="theFrom" method="post" action="/oversea/savepurchasing">
                    	 <p>
                        	<label>申请人：</label>
                            <span class="field">
                            {{$username}}</span>
                        </p>
                          <p>
                        	<label>始发地</label>
                            <span class="field">
                            <select name="starthouse" id="starthouse" class="selection select2_group" style="width:200px;">
                            	 <option value="" >请选择</option>
                               {{foreach from=$overseawarehouse item=li key=key}}
                               		{{if $myseawarehouse}}
                               		  {{if in_array($li.name,$myseawarehouse)}} 
                               			 <option value="{{$li.name}}" {{if $li.name=='2号仓库 (C2)'}} selected{{/if}} >{{$li.name}}</option>
                                	  {{/if}}
                                    {{else}}
                               			 <option value="{{$li.name}}" {{if $li.name=='2号仓库 (C2)'}} selected{{/if}}  >{{$li.name}}</option>
                                    {{/if}}
                               {{/foreach}}
                            </select>
                            </span>
                        </p>
                    	 <p>
                        	<label>发往仓库</label>
                            <span class="field">
                            <select name="seawarehouse"  id="seawarehouse" class="selection select2_group" style="width:200px;" onChange="getcang()" >
                            	 <option value="" >请选择</option>
                               {{foreach from=$overseawarehouse item=li key=key}}
                               		{{if $myseawarehouse}}
                               		  {{if in_array($li.name,$myseawarehouse)}} 
                               			 <option value="{{$li.name}}" >{{$li.name}}</option>
                                	  {{/if}}
                                    {{else}}
                               			 <option value="{{$li.name}}" >{{$li.name}}</option>
                                    {{/if}}
                               {{/foreach}}
                            </select>
                            </span>
                        </p>
                        <p>
                        	<label>店铺：</label>
                            <span class="field">
                             <select name="shopname" id="shopname"  class="selection select2_group" style="width:200px;" >
                             <option value="" >请选择</option>
                               {{foreach from=$d_shop item=li key=key}}
                              	 {{if $myshopname}}
                                     {{if in_array($li.name,$myshopname)}} 
                                     <option value="{{$li.name}}" >{{$li.name}}</option>
                                     {{/if}}
                                 {{else}}
                                 	  <option value="{{$li.name}}" >{{$li.name}}</option>
                                 {{/if}}
                               {{/foreach}}
                            </select></span>
                        </p>
					
                     <p>
                        	<label>运输方式
</label>
                            <span class="field">
                           <select class="selection" id="transportmode" name="transportmode"  style="width:200px;">
										<option value="">-请选择-</option>
						    	 {{foreach from=$transportmodelist item=li key=key}}
					    			<option value="{{$li}}">{{$li}}</option>
					  	     	{{/foreach}}
									</select>


 <span id=showerr></span>
                            </span>
                           
                        </p>
						<p>
							<label>搜索商品信息</label>
                            <span class="field">
	                            <input type="text" id="psearch_key" name="psearch_key"  style="width:200px;"  value="" placeholder="SKU,商品中文">
	                            <img src="/fuman/images/search1.png" style="cursor:pointer" id="p_search"><br/>
	                            <span id="search_content"></span>
                            </span>

						</p>

                        <p>
                        	<label>SKU：</label>
                            <span class="field"><textarea name="sku" id="sku" cols="50" rows="5" class="longinput"></textarea>
                            <small class="desc">SKU一行一个</small>
                            </span>
                        </p>

                       	<p>
                        	<div id="showskulist"></div>
                        </p>
                        
                        
                        <p class="stdformbutton">
                        	<span id="prespan"><button type="button" class="submit radius2" id="btn" onClick="purchasingNext()">NEXT</button></span>
                        </p>
                    </form>
					
                    <br />

            </div><!--subcontent-->
            
            <!--subcontent-->
        
        </div><!--contentwrapper-->
        
	</div><!-- centercontent -->
    
    
</div><!--bodywrapper-->

</body>
</html>
